﻿using Microsoft.SharePoint.ApplicationPages.Calendar.RecurrenceRule;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace WindStyle.SPCalendar.Pattern
{
    public class MonthlyByFrequencyPattern : IPattern
    {
        public int Day { get; set; }
        public int MonthFrequency { get; set; }

        public MonthlyByFrequencyPattern()
        {
            this.Day = DateTime.Today.Day;
            this.MonthFrequency = 1;
        }

        public string ToXML()
        {
            return string.Format("<monthly monthFrequency=\"{0}\" day=\"{1}\" />",
                    this.MonthFrequency,
                    this.Day);
        }

        public void FromRule(RecurrenceRule recurrence)
        {
            this.MonthFrequency = recurrence.Frequency;
            this.Day = recurrence.Day;
        }
    }

}
